/*
 * Copyright (c) 2005, 2014 vacoor
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 */
Ext.define('Nothing.view.module.ModuleManage', {
    extend: 'Nothing.ux.panel.DataViewer',
    // extend: 'Nothing.ux.grid.DataGrid',
    alias: ['widget.moduleMgt'],
    uses: ['Nothing.ux.form.TreePicker', 'Ext.ux.form.field.ClearButton'],

    store: 'Modules',
    autoGenItems: true,
    exportEnabled: false,

    items: [
        {
            name: 'sort',
            fieldType: 'I'
        },
        {
            name: 'enabled',
            fieldType: 'B',
            xtype: 'combo',
            enableAllOption: true,
            store: [
                [1, '启用'],
                [0, '禁用']
            ]
        },
        {
            fieldLabel: '下拉树',
            name: 'id',
            xtype: 'treepicker',
            selectLeafOnly: false,
            store: Ext.create('Nothing.store.Trees')
        }
    ],

    columns: [
        {

            header: '模块名称',
            dataIndex: 'name',
            flex: 1,
            editor: {
                xtype: 'textfield'/*,
                 allowBlank: false*/
            }
        },
        {
            header: '模块值',
            dataIndex: 'value',
            flex: 1,
            editor: 'textfield'
        },
        {
            header: 'URL',
            dataIndex: 'url',
            flex: 1,
            editor: 'textfield'
        },
        {
            header: '描述',
            dataIndex: 'description',
            flex: 1,
            editor: 'textfield'
        },
        {
            header: '排序',
            dataIndex: 'sort',
            flex: 1,
            editor: 'numberfield'
        },
        {
            header: '状态',
            xtype: 'booleancolumn',
            trueText: '启用',
            falseText: '禁用',
            dataIndex: 'enabled',
            flex: 1,
            editor: {
                xtype: 'combo',
                forceSelection: true,
                store: [
                    [1, '启用'],
                    [0, '禁用']
                ]
            }
        },
        {
            header: '父模块',
            //xtype: 'templatecolumn',
            // for 循环
            //tpl: '{parentName}<tpl if="parentId">({parentId})</tpl>',
            // parent 指向父模板, 如果有parent属性肿么办?
            // tpl: '<tpl for="parentName">{.}<tpl if="xindex < xcount">, </tpl></tpl>',
            //tpl: '<tpl for="parentName">{.} <tpl if="[parent.parentId[xindex - 1]]">({[parent.parentId[xindex - 1]]})<tpl if="xindex < xcount">, </tpl></tpl></tpl>',
            dataIndex: 'parent.name',
            editor: {
                name: 'parent.id',
                rawValueUpdateField: 'parent.name',
                xtype: 'treepicker',
                selectLeafOnly: false,
                rootVisible: true,
                store: Ext.create('Nothing.store.Trees')
            }
        },
        {
            header: '控制器',
            dataIndex: 'controller',
            flex: 1,
            editor: 'textfield'
        },
        {
            header: '面板类型',
            dataIndex: 'xtype',
            flex: 1,
            editor: 'textfield'
        }
    ]
});
